package com.thz.friend.controller.reply;

import com.thz.common.core.controller.BaseController;
import com.thz.common.core.result.Result;
import com.thz.friend.pojo.reply.Reply;
import com.thz.friend.pojo.reply.vo.ReplyVO;
import com.thz.friend.service.reply.IReplyService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description
 * @Author thz
 * @Date 2025/5/11
 */
@RestController
@RequestMapping("/reply")
public class ReplyController {
    @Autowired
    private IReplyService replyService;

    @PostMapping("/add")
    public Result<Long> addReply(@RequestBody Reply reply) {
        return Result.ok(replyService.addReply(reply));
    }

    @GetMapping("/list")
    public Result<List<ReplyVO>> list(@RequestParam Long courseId,
                                      @RequestParam(defaultValue = "1") Integer pageNum,
                                      @RequestParam(defaultValue = "10") Integer pageSize) {
        return Result.ok(replyService.listByCourseId(courseId, pageNum, pageSize));
    }
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable Long id) {
        return Result.ok(replyService.deleteReply(id));
    }
}